/* Lua CJSON floating point conversion routines */

/* Buffer required to store the largest string representation of a double.
 *
 * Longest double printed with %.14g is 21 characters long:
 * -1.7976931348623e+308 */
#ifndef _FPCONV_H
#define _FPCONV_H 1

# define FPCONV_G_FMT_BUFSIZE   32
//#define USE_INTERNAL_FPCONV
#ifdef USE_INTERNAL_FPCONV
static inline void fpconv_init()
{
    /* Do nothing - not required */
}
#else
extern inline void fpconv_init();
#endif

extern int fpconv_g_fmt(char*, double, int);
extern double fpconv_strtod(const char*, char**);
#ifndef NPY_HAVE_DECL_ISNAN
#define npy_isnan(x) ((x) != (x))
#else
#ifdef _MSC_VER
#define npy_isnan(x) _isnan((x))
#else
#define npy_isnan(x) isnan((x))
#endif
#endif

#ifndef NPY_HAVE_DECL_ISFINITE
#ifdef _MSC_VER
#define npy_isfinite(x) _finite((x))
#else
#define npy_isfinite(x) !npy_isnan((x) + (-x))
#endif
#else
#define npy_isfinite(x) isfinite((x))
#endif

#ifndef NPY_HAVE_DECL_ISINF
#define npy_isinf(x) (!npy_isfinite(x)&&!npy_isnan(x))
#else
#ifdef _MSC_VER
#define npy_isinf(x) (!_finite(x) && !_isnan(x))
#else
#define npy_isinf(x) isinf((x))
#endif
#endif
#endif
/* vi:ai et sw=4 ts=4:
 */
